<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../assets/js/vue.js"></script>
    <style>
        .text{
            width: 300px;
            position: absolute;
            top: 20px;
            right: 20px;
            overflow: hidden;

        }
        .tip{
            width: 100%;
            height: 40px;
            line-height: 40px;
            background-color: teal;
            color: white;
            margin-bottom: 10px;
            border-radius: 10px;
            animation: showTip 3s ease-in;
        }
        @keyframes showTip{
            0%{
                transform: translate(120%,0px);
            }
            10%{
                transform: translate(0%,0px);
            }
            90%{
                transform: translate(0%,0px);
            }
            100%{
                transform: translate(120%,0px);
            }
        }

    </style>
</head>
<body>
    <div id="app">
        
    </div>
    <input type="button" value="创建实例" onclick="showVm()">
    <script>
        // new Vue({
        //     template:`
        //     <div> 创建实例</div>`
        // })
        var divDom=null;
        function showVm(){
                if(!divDom){
                    divDom=document.createElement("div");
                    divDom.className="text";
                    document.body.append(divDom);
                }
                var myVm=new Vue({
                template:`
                <div class="tip"> 创建实例 {{ msg }}</div>`,
                data:{
                    msg:Math.random()
                }
            })
            console.log(myVm);
            console.log(myVm.$el);
            myVm.$mount();
            console.log(myVm.$el);
            divDom.append(myVm.$el);
            setInterval(function(){
                divDom.removeChild(myVm.$el);
                divDom.$destory();
            },3000)
        }
    </script>
</body>
</html>